package com.zhb.designmode.creationmode.factory.easyfactory.fatory;

import com.zhb.designmode.creationmode.factory.easyfactory.product.BMW;
import com.zhb.designmode.creationmode.factory.easyfactory.product.Benz;
import com.zhb.designmode.creationmode.factory.easyfactory.product.Car;

public class CarFactory {

    public static Car getCar(String name){
        if("宝马".equals(name)){
            return new BMW();
        }
        if("奔驰".equals(name)){
            return new Benz();
        }
        return new Car() {
            public String getName() {
                return "null";
            }
        };
    }

}
